package indi.gao.redis;


import org.apache.commons.io.IOUtils;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.web.multipart.MultipartFile;

import java.io.*;

/**
 * <p>Description:</p>
 * <p>Copyright: Copyright (c)2019$</p>
 * <p>Company: Tope</p>
 * <P>Created Date :2019$-08$-09$</P>
 * <P>@version 1.0</P>
 */
public class StringText {
    public static void main(String[] args) {
        try {
//            创建临时文件
            final File txtTempFile = File.createTempFile("ReplaceInsert", ".txt");
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(txtTempFile)));
            bw.write("gaolei");
            bw.flush();
            bw.close();
            FileInputStream input = new FileInputStream(txtTempFile);

            MultipartFile multipartFile = new MockMultipartFile("file", txtTempFile.getAbsolutePath(), "text/plain", IOUtils.toByteArray(input));
            System.out.println(txtTempFile.getAbsolutePath());
            txtTempFile.deleteOnExit();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
